home *** CD-ROM | disk | FTP | other *** search
- { buttonu.pas -- Check box and radio button unit }
-
- unit ButtonU;
-
- interface
-
- uses WinTypes, WinProcs;
-
- type
-
- CBSet = Set of 0 .. 15; { Set of up to 16 check boxes }
- RadioSet = CBSet; { Set of up to 16 radio buttons }
-
- procedure SetChecks(HDlg: HWnd; C: CBSet; FirstID, LastID: Word);
- procedure SetRadios(HDlg: HWnd; R: RadioSet; FirstID, LastID: Word);
- procedure GetChecks(HDlg: HWnd; var C: CBSet; FirstID, LastID: Word);
-
- implementation
-
- {- Limit LastID to FirstID + 15 }
- procedure LimitIDs(FirstID: Word; var LastID: Word);
- var
- MaxLastID: Word;
- begin
- MaxLastID := FirstID + 15;
- if LastID > MaxLastID
- then LastID := MaxLastID
- end;
-
- {- Set check boxes according to values in C for dialog HDlg. FirstID
- should be the ID of the first check box control in this series.
- LastID should be the ID of the last box in the series. }
-
- procedure SetChecks(HDlg: HWnd; C: CBSet; FirstID, LastID: Word);
- var
- I: Integer;
- begin
- LimitIDs(FirstID, LastID);
- for I := 0 to LastID - FirstID do
- if I in C then
- SendDlgItemMessage(HDlg, I + FirstID, bm_SetCheck, 1, 0)
- end;
-
- {- Set radio buttons according to values in set R for dialog HDlg.
- The FirstID parameter must be the ID of the first radio button in
- this series. LastID must be the ID of the last button in the series.
- No radio button should have its Tabstop bit set in the resource,
- however the first radio button must have the group bit set. This
- configuration allows the input focus to move between groups for Tab
- and Shift+Tab, and within groups for Arrow keys. }
-
- procedure SetRadios(HDlg: HWnd; R: RadioSet; FirstID, LastID: Word);
- var
- I: Integer;
- HControl: HWnd;
- StyleBits: Word;
- begin
- LimitIDs(FirstID, LastID);
- for I := 0 to LastID - FirstID do if (I in R) then
- begin
- HControl := GetDlgItem(HDlg, FirstID + I);
- SendMessage(HControl, bm_SetCheck, 1, 0);
- end
- end;
-
- {- Retrieve check box or radio button settings into C. }
- procedure GetChecks(HDlg: HWnd; var C: CBSet; FirstID, LastID: Word);
- var
- I: Integer;
- begin
- LimitIDs(FirstID, LastID);
- C := [];
- for I := 0 to LastID - FirstID do
- if SendDlgItemMessage(HDlg, I + FirstID, bm_GetCheck, 0, 0) <> 0
- then C := C + [I]
- end;
-
- end.
-
-
- {--------------------------------------------------------------
- Copyright (c) 1991 by Tom Swan. All rights reserved.
- Revision 1.00 Date: 3/19/1991
- Revision 1.01 Date: 11/1/1991
- 1, Removed following statements from SetRadios procedure
- StyleBits := GetClassWord(HControl, gcw_Style);
- SetClassWord(HControl, gcw_Style, StyleBits or ws_Tabstop)
- ---------------------------------------------------------------}
-